import React from 'react'
import { NavBar, Space, Toast } from 'antd-mobile'
import http from '../../api/request'
import { List, Switch } from 'antd-mobile'
import { useNavigate, useSearchParams } from 'react-router-dom'
import { Wechat,Alipay,WechatPay } from '@react-vant/icons';
function Index() {
  const [sp] = useSearchParams()
  const start = sp.get('start')
  const end = sp.get('end')
  const price = sp.get('price')
  const startTime = sp.get('startTime')
  const endTime = sp.get('endTime')
  const time = sp.get('time')
  const title='请支付'
  const cc = sp.get('cc')
  const id = sp.get('id')
  console.log(price,id);
  
  const zf=()=>{
    http.get('/api/pay',{
      params:{
        id,price,title
      }
    }).then((res)=>{
      console.log(res);
      if(res.code===200){
        window.location.href=res.data
      }else{
        Toast.show('支付失败')
      }
    })
  }
  const nav=useNavigate()
  return (
    <div>
      <div>
      <NavBar onBack={()=>nav(-1)}>标题</NavBar>
      </div>
        <List>
        <List.Item onClick={()=>zf()}> <Alipay/> 支付宝</List.Item>
        <List.Item onClick={()=>Toast.show('微信支付还未开启')}> <Wechat/> 微信</List.Item>
        <List.Item onClick={()=>Toast.show('银行卡支付还未开启')}><WechatPay/> 银行卡</List.Item>
      </List>
    </div>
  )
}

export default Index
